﻿using AbstractBugTracker;
using AbstractProducts;

namespace JiraRest
{
    internal sealed class JiraBugRef : BugRef
    {
        internal JiraBugRef(BugRef bugRef)
            : base(bugRef.ProductRef, JiraUtils.Clean(bugRef.MethodTypeName, false), GetMethodName(bugRef), JiraUtils.Clean(bugRef.ExceptionTypeName, false), bugRef.ExceptionReportHash == null ? null : JiraUtils.Clean(bugRef.ExceptionReportHash, false))
        {
        }

        private static string GetMethodName(BugRef bugRef)
        {
            string methodName = JiraUtils.Clean(bugRef.MethodName, false);
            return methodName == "" ? "Unknown because of SA-851" : methodName;
        }

        internal JiraBugRef(ProductRef productRef, string methodTypeName, string methodName, string exceptionTypeName, string exceptionReportHash, IExceptionReportMapper exceptionReportMapper)
            : base(productRef, exceptionReportMapper.MapMethodTypeName(methodTypeName), methodName, exceptionReportMapper.MapExceptionTypeName(exceptionTypeName), exceptionReportHash)
        {
        }
    }
}
